<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  request.setAttribute("now",new Date());
%>

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <h3 class="panel-title">会议安排登记表</h3>
            </div>

            <div style="margin: 10px">

                <!-- Nav tabs -->
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#bsc-tab-1" data-toggle="tab">会议安排登记表</a></li>
                    <c:if test="${meeting.numStatus==1}">
                        <li><a href="#bsc-tab-2" data-toggle="tab">历史副本</a></li>
                        <li><a href="#bsc-tab-3" data-toggle="tab">会议纪要</a></li>
                        <li><a href="#bsc-tab-4" data-toggle="tab">会议考勤</a></li>
                    </c:if>
                </ul>

                <!-- Tabs Content -->
                <div class="tab-content">

                    <div class="tab-pane pad-btm fade in active" id="bsc-tab-1">
                        <!-- BASIC FORM ELEMENTS -->
                        <!--===================================================-->
                        <form id="form_meeting_input" class="panel-body form-horizontal form-padding">
                            <input type="hidden" name="keyId" id="keyId" value="${meeting.id}" />
                            <input type="hidden" name="updateUnid" id="updateUnid" value="${meeting.updateUnid}" />
                            <div class="form-group">
                                <label class="col-md-2 control-label">是否外出会议<i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="isOut" name="isOut" class="form-control" value="${meeting.isOut==1?"是":"否"}" disabled>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">日程公开<i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="isPublic" name="isPublic" class="form-control" value="${meeting.isPublic==1?"是":"否"}" disabled>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">会议名称<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="name" name="name" class="form-control" disabled value="${meeting.name}">
                                </div>
                            </div>

                            <div class="form-group div-Hidden">
                                <label class="col-md-2 control-label">开始日期<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-2">
                                    <div class="input-group date">
                                        <input type="text" class="form-control" id="datStart" name="datStart" disabled
                                               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${meeting.datStart}" /> >
                                        <span class="input-group-addon"><i class="ti-calendar"></i></span>
                                    </div>
                                </div>
                                <label class="col-md-2 control-label">开始时间<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-2">
                                    <div class="input-group clockpicker">
                                        <input type="text" class="form-control" id="timStart" name="timStart" disabled
                                               value=<fmt:formatDate pattern="HH:mm" value="${meeting.timStart}" /> >
                                        <span class="input-group-addon"><i class="ti-alarm-clock"></i></span>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group div-Hidden">
                                <label class="col-md-2 control-label">结束日期<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-2">
                                    <div class="input-group date">
                                        <input type="text" class="form-control" id="datEnd" name="datEnd" disabled
                                               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${meeting.datEnd}" /> >
                                        <span class="input-group-addon"><i class="ti-calendar"></i></span>
                                    </div>
                                </div>
                                <label class="col-md-2 control-label">结束时间<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-2">
                                    <div class="input-group clockpicker">
                                        <input type="text" class="form-control" id="timEnd" name="timEnd" disabled
                                               value=<fmt:formatDate pattern="HH:mm" value="${meeting.timEnd}" /> >
                                        <span class="input-group-addon"><i class="ti-alarm-clock"></i></span>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">会议议题<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="subject" name="subject" class="form-control" disabled value="${meeting.subject}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">
                                    会议负责人
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="userName" name="userName" class="form-control" disabled value="${meeting.chief.name}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">
                                    内部参会人员
                                    <i class="fa fa-asterisk txt-color-red"></i>
                                </label>
                                <div class="col-md-6">
                                    <input type="text" id="userNames" name="userNames" class="form-control" disabled
                                           value="<c:forEach var="item" items="${meeting.participants}" varStatus="status">${item.name}<c:if test="${!status.last}">,</c:if></c:forEach>">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">外部参会人员</label>
                                <div class="col-md-6">
                                    <input type="text" id="outermen" name="outermen" class="form-control" disabled value="${meeting.outermen}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">具体地点<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="address" name="address" class="form-control" disabled value="${meeting.address}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">会议辅助设备
                                    <span style="display: none" id="aidSetsSpan">${meeting.aidSets}</span>
                                </label>
                                <div class="col-md-6">

                                    <div class="checkbox">
                                        <!-- Inline checkbox buttons -->
                                        <input type="checkbox" name="aidSets" id="aidSets1Selected" class="magic-checkbox" value="01" disabled
                                        <c:if test="${meeting.aidSets.indexOf('01')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets1Selected">电脑</label>

                                        <input type="checkbox" name="aidSets" id="aidSets2Selected" class="magic-checkbox" value="02" disabled
                                        <c:if test="${meeting.aidSets.indexOf('02')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets2Selected">投影仪</label>

                                        <input type="checkbox" name="aidSets" id="aidSets3Selected" class="magic-checkbox" value="03" disabled
                                        <c:if test="${meeting.aidSets.indexOf('03')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets3Selected">激光笔</label>

                                        <input type="checkbox" name="aidSets" id="aidSets4Selected" class="magic-checkbox" value="04" disabled
                                        <c:if test="${meeting.aidSets.indexOf('04')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets4Selected">白板</label>

                                        <input type="checkbox" name="aidSets" id="aidSets5Selected" class="magic-checkbox" value="05" disabled
                                        <c:if test="${meeting.aidSets.indexOf('05')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets5Selected">话筒音响</label>

                                        <input type="checkbox" name="aidSets" id="aidSets6Selected" class="magic-checkbox" value="06" disabled
                                        <c:if test="${meeting.aidSets.indexOf('06')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets6Selected">人名牌</label>

                                        <input type="checkbox" name="aidSets" id="aidSets7Selected" class="magic-checkbox" value="07" disabled
                                        <c:if test="${meeting.aidSets.indexOf('07')>-1}"> checked="checked"</c:if> >
                                        <label for="aidSets7Selected">其他</label>

                                    </div>
                                </div>
                            </div>

                            <div class="form-group" id="otherSetDiv">
                                <label class="col-md-2 control-label">其他辅助设备<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="otherSet" name="otherSet" class="form-control" disabled value="${meeting.otherSet}">
                                </div>
                            </div>

            <c:if test="${meeting.txtStatus.equals('已取消')}">
                            <div class="form-group">
                                <label class="col-md-2 control-label">取消原因<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="cancelReason" name="cancelReason" class="form-control" disabled value="${meeting.cancelReason}">
                                </div>
                            </div>
            </c:if>

                            <div class="form-group">
                                <label class="col-md-2 control-label">提交人</label>
                                <div class="col-md-2">
                                    <p class="form-control-static">${meeting.creater.name}</p>
                                </div>
                                <label class="col-md-2 control-label">提交日期</label>
                                <div class="col-md-2">
                                    <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${meeting.dateApply}" /></p>
                                </div>
                            </div>
                        </form>
                        <!--===================================================-->
                        <!-- END BASIC FORM ELEMENTS -->

                        <div class="panel-footer">
                            <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
                                <i class="fa fa-lg fa-mail-reply"></i> 返回视图
                            </a>
                            <c:if test="${meeting.numStatus!=-1 && user.id==meeting.chief.id && meeting.timStart.getTime()>now.getTime()}">
                                <a class="btn btn-warning" key="ajax_meeting_cancel" href="javascript:void(0);"><i class="fa fa-lg fa-minus"></i> 会议取消 </a>
                                <a class="btn btn-warning" key="ajax_meeting_edit" href="javascript:void(0);"><i class="fa fa-lg fa-edit"></i> 会议调整 </a>
                            </c:if>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-2">
                        <div class="table-responsive" style="min-height: 530px;margin: 10px">
                            <table id="meeting_history_table"></table>
                            <div id="meeting_history_page"></div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-3">
                        <form id="form_meeting_file" class="panel-body form-horizontal form-padding">
                            <c:choose>
                                <c:when test="${meeting.fileAttachment != null}">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">
                                            会议纪要
                                        </label>
                                        <div class="col-md-6">
                                            <input name="hiddenFiles" id="hiddenFilesAttachmentRead" type="hidden" value="${meeting.fileAttachment}">
                                        </div>
                                    </div>
                                </c:when>
                                <c:otherwise>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">
                                            会议纪要
                                        </label>
                                        <div class="col-md-6">
                                            <input name="uploadify" id="fileAttachment" placeholder="" type="file" >
                                            <input name="hiddenFiles" id="hiddenFilesAttachment" type="hidden" value="${meeting.fileAttachment}">
                                        </div>
                                        <div class="col-md-4">
                                            <a class="btn btn-warning" onclick="fn_meeting_upload_file()" href="javascript:void(0);"><i class="fa fa-upload"></i> 保存纪要 </a>
                                        </div>
                                    </div>
                                </c:otherwise>
                            </c:choose>

                        </form>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-4">
                        <div class="table-responsive" style="min-height: 530px;margin: 10px">
                            会议考勤
                        </div>

                        <%--<div class="table-responsive" style="min-height: 530px;margin: 10px">--%>
                            <%--<table id="meeting_check_table"></table>--%>
                            <%--<div id="meeting_check_page"></div>--%>
                        <%--</div>--%>
                    </div>

                </div>
            </div>

        </div>
    </div>
</div>

<script>

    <c:choose>
    <c:when test="${meeting.fileAttachment != null}">
    // 附件显示
    readLoad({
        objId:"hiddenFilesAttachmentRead",
        entityName:"fileAttachment",
        sourceId:"hiddenFilesAttachmentRead"
    });
    </c:when>
    <c:otherwise>
    // 附件上传
    inputLoad({
        objId:"fileAttachment",
        entityName:"fileAttachment",
        sourceId:"hiddenFilesAttachment"
    });
    </c:otherwise>
    </c:choose>





    //返回视图
    $("#apply-re-common").click(returnToHashUrl);

    function fn_meeting_cancel_submit(keyId, reason){
        //ajax执行返回时触发
        var url = '<%=path %>/activiti/meeting/cancel';
        var data = { keyId: keyId, cancelReason: reason};
        __ajax_post(url, data, function(data){
            __toastr(data);
            if(data.state == 1) {
                returnToHashUrl();
            }
        });
    }

    $("a[key='ajax_meeting_cancel']").unbind("click").bind("click",function(){
        __confirm_dialog_input('取消原因', '请输入取消原因', "", function (dialogRef, inputValue) {
            if (inputValue) {
                dialogRef.close();

                fn_meeting_cancel_submit($("#keyId").val(), inputValue);
            } else {
                dialogRef.enableButtons();

                __toastr_warning('请输入取消原因');
            }
        });

    });

    //编辑
    $("a[key='ajax_meeting_edit']").unbind("click").bind("click",function(){
        __confirm_dialog("提示：","确定要修改会议吗？",
            function () {
                // 加载编辑页面
                loadURL("<%=path%>/activiti/meeting/edit/"+$("#keyId").val(),$('#page-content'));
            }
        )
    });

    function fn_meeting_upload_file() {
        $.ajax({
            url: '<%=path%>/activiti/meeting/uploadfile',
            type: "POST",
            cache: false,
            dataType: 'json',
            data: {
                keyId: $("#keyId").val(),
                hiddenFiles: $("input[name='hiddenFiles']").eq(0).val(),
                fileAttachment: $("input[name='fileAttachment']").eq(0).val()
            },
            success: function(data) {
                __toastr(data);
            },
            error:function() {
                __toastr_error('上传数据出错');
            }
        });
    }

    // 加载完成后执行
    $(function(){
        var aidSets = $("#aidSetsSpan").text();
        if(aidSets.indexOf("07")>-1){
            $("#otherSetDiv").show();
        } else {
            $("#otherSetDiv").hide();
        }

        init_grid_meeting_history();
    })

    function init_grid_meeting_history() {

        __init_jqgrid('meeting_history_table', 'meeting_history_page',
            '<%=path%>/activiti/meeting/listHistory?updateUnid='+$("#updateUnid").val(),
            ['会议名称', '会议地点', '会议负责人', '调整日期', '操作', 'id'],
            [
                {name: 'name', index: 'name', width: 150, sortable: false, search: false},
                {name: 'address', index: 'address', width: 100, sortable: false, search: false},
                {name: 'chief', index: 'chief', width: 80, sortable: false, search: false},
                {name: 'dateUpdate', index: 'dateUpdate', width: 80, sortable: false, search: false},
                {name: 'act', index: 'act', width: 100, fixed: true, sortable: false, search: false, formatter: actFormat},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                autowidth: false,
                height: 500
            }
        );

    }

    function actFormat(cellvalue, options, rowObject){
        var id = rowObject.id;
        cellvalue = '<button class="btn btn-white btn-sm" data-original-title="查看" onclick="fn_meeting_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button> ';
        return cellvalue;
    }

    function fn_meeting_read(id) {
        var url = '<%=path%>/activiti/meeting/read/'+id;
        __open_dialog_form_read('会议安排', url);
    }
</script>




